const glob = require('glob');
let reg = /([^\\/]+)\.([^\\/]+)/i,pages={};
glob.sync('./public/*.html').forEach(item=>{
    let filename = item.match(reg)[1];
    pages[filename] = `src/${filename}.js`
})
console.log(pages)
module.exports = {
    devServer: {
        host:'localhost',
        port: '8090',
        // proxy: 'http://localhost:8090'
        overlay: {
            warnings: true,
            errors: true
        }
    },
    lintOnSave: false,
    publicPath:'./',
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            process.env.NODE_ENV = 'production'
        } else {
            process.env.NODE_ENV = 'development'
        }
    },
    // POSTCSS
    css: {
        loaderOptions: {
            postcss: {
                plugins: [
                    require('postcss-px2rem')({
                        remUnit : 75, // 换算的基数
                    }),
                ]
            }
        }
    },
    pages
    // pages: {
    //     index: {
    //       entry: 'src/index.js',
    //       filename: 'index.html',
    //       title: 'Index Page',
    //       chunks: ['chunk-vendors', 'chunk-common', 'index']
    //     },
    //     sePage: {
    //         // page 的入口
    //         entry: 'src/sePage.js',
    //         filename: 'sePage.html',
    //         title: 'second Page',
    //         chunks: ['chunk-vendors', 'chunk-common', 'sePage']
    //     },
    //     thirdPage: 'src/thirdPage.js'
    // },
    
}